package com.sk.controller;

import com.sk.constant.Constants;
import com.sk.mapper.SClassMapper;
import com.sk.pojo.RespBean;
import com.sk.pojo.SClass;
import com.sk.server.ClassServer;
import com.sk.service.impl.SClassServiceImpl;
import com.sk.utils.FdfsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("class")
public class ClassController {
    String ip = Constants.IP;
    @Autowired
    FdfsUtils fastDFSUtil;

    @Autowired
    SClassServiceImpl sClassService;

    @Autowired
    SClassMapper sClassMapper;

    @Autowired
    ClassServer classServer;

    @PostMapping("add")
    public RespBean add(@RequestParam("name")String name, @RequestParam("file")MultipartFile file){
        return classServer.add(name,file);
    }


    @PostMapping("like")
    public RespBean  like(String name) {
        return RespBean.success("查找成功",classServer.like(name));
    }

    @PostMapping("delete")
    public RespBean delete(@RequestParam("id")Integer id) {
        return classServer.delete(id);
    }

    @PostMapping("update")
    public RespBean update(@RequestParam("id")Integer id,String name, MultipartFile file) {
        return classServer.update(id, name, file);
    }

}
